/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.grt192.controller.breakaway.teleop;
import com.grt192.core.EventController;
import com.grt192.event.SensorEvent;
import com.grt192.event.component.ButtonListener;
import com.grt192.mechanism.GRTDriverStation;
import com.grt192.mechanism.breakaway.Recovery;
import com.grt192.sensor.GRTJoystick;
/**
 *
 * @author klian
 */
public class RecoveryController extends EventController implements ButtonListener{

    public RecoveryController(GRTDriverStation dStation, Recovery arm){
        super();
        addMechanism("DriverStation", dStation);
        addMechanism("Arm", arm);
        ((GRTJoystick) dStation.getSensor("secondaryJoystick")).addButtonListener(this);
    }

    public void buttonUp(SensorEvent e, String key) {
        if(key.equals("Button4") || key.equals("Button6"))
            ((Recovery) getMechanism("Arm")).stopArm();
    }

    public void buttonDown(SensorEvent e, String key) {
        if(key.equals("Button4")){
            ((Recovery) getMechanism("Arm")).flip();
        }else if(key.equals("Button6")){
            ((Recovery) getMechanism("Arm")).retract();
        }
    }
}
